import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { usePermissStore } from './store/permiss';


import App from './App.vue'
import router from './router';
import '@/assets/css/main.css'
import '@/assets/css/reset.scss'
import './assets/css/icon.css';

import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css';
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'


const app = createApp(App);
app.use(router);
app.use(createPinia());
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }

// 自定义权限指令
const permiss = usePermissStore();
app.directive('permiss', {
    mounted(el, binding) {
        if (binding.value && !permiss.key.includes(String(binding.value))) {
            el['hidden'] = true;
        }
    },
});
app.config.globalProperties.$message = ElMessage
app.config.globalProperties.$msgBox = ElMessageBox
app.config.globalProperties.$loading = ElLoading

app.mount('#app');
